package com.reform.mapper;

import com.reform.pojo.phase.BatchInfoIncludeDelay;
import com.reform.pojo.phase.BatchName;
import com.reform.pojo.phase.ViewBatch;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * VIEW Mapper 接口
 * </p>
 *
 * @author mortale
 * @since 2021-08-06
 */
@Mapper
public interface ViewBatchMapper extends BaseMapper<ViewBatch> {

    /**
     * 根据phaseId获取BatchId
     * @param phaseId
     * @return
     */
    @Select("SELECT batch_id FROM batch_phase WHERE phase_id = #{phaseId}")
    List<String> getBatchIdByPhaseId(@Param("phaseId") String phaseId);

    /**
     * 获取批次id和名称
     * @return
     */
    @Select(
            "SELECT\n" +
                    "	view_batch.batch_name AS batchName, \n" +
                    "	view_batch.batch_id AS batchId\n" +
                    "FROM\n" +
                    "	view_batch\n" +
                    "WHERE\n" +
                    "	view_batch.type = 1"
    )
    List<BatchName> getBatchName();

    @Select(
            "SELECT\n" +
                    "	view_batch.batch_name AS batchName, \n" +
                    "	view_batch.company, \n" +
                    "	view_batch.level_name AS levelName, \n" +
                    "	view_batch.batch_id AS batchId\n" +
                    "FROM\n" +
                    "	view_batch\n" +
                    "WHERE\n" +
                    "	view_batch.batch_id = #{batchId} AND\n" +
                    "	view_batch.status = #{status}"

    )
    BatchInfoIncludeDelay getBatchInfoIncludeDelay(@Param("batchId") String batchId,@Param("status")Integer status);
}
